/*
 *  Copyright 2011 yura.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.vcforms.transform_t2d.var.calc;

import java.io.ByteArrayInputStream;

/**
 * A Bison parser, automatically generated from <tt>ltcalc.y</tt>.
 *
 * @author LALR (1) parser skeleton written by Paolo Bonzini.
 */
public class YYParser {

    /** Version number for the Bison executable that generated this parser.  */
    public static final String bisonVersion = "2.4.3";
    /** Name of the skeleton that generated this parser.  */
    public static final String bisonSkeleton = "lalr1.java";
    /** True if verbose error messages are enabled.  */
    public boolean errorVerbose = false;
    /** Token returned by the scanner to signal the end of its input.  */
    public static final int EOF = 0;

    /* Tokens.  */
    /** Token number, to be returned by the scanner.  */
    public static final int NUM = 258;
    /** Token number, to be returned by the scanner.  */
    public static final int NEG = 259;
    /** The object doing lexical analysis for us.  */
    private Lexer yylexer;

    /**
     * Instantiates the Bison-generated parser.
     * @param yylexer The scanner that will supply tokens to the parser.
     */
    public YYParser(Lexer yylexer) {
        this.yylexer = yylexer;

    }
    private java.io.PrintStream yyDebugStream = System.err;

    /**
     * Return the <tt>PrintStream</tt> on which the debugging output is
     * printed.
     */
    public final java.io.PrintStream getDebugStream() {
        return yyDebugStream;
    }

    /**
     * Set the <tt>PrintStream</tt> on which the debug output is printed.
     * @param s The stream that is used for debugging output.
     */
    public final void setDebugStream(java.io.PrintStream s) {
        yyDebugStream = s;
    }
    private int yydebug = 0;

    /**
     * Answer the verbosity of the debugging output; 0 means that all kinds of
     * output from the parser are suppressed.
     */
    public final int getDebugLevel() {
        return yydebug;
    }

    /**
     * Set the verbosity of the debugging output; 0 means that all kinds of
     * output from the parser are suppressed.
     * @param level The verbosity level for debugging output.
     */
    public final void setDebugLevel(int level) {
        yydebug = level;
    }

    private int yylex() throws java.io.IOException {
        return yylexer.yylex();
    }

    protected final void yyerror(String s) {
        yylexer.yyerror(s);
    }

    protected final void yycdebug(String s) {
        if (yydebug > 0) {
            yyDebugStream.println(s);
        }
    }

    private final class YYStack {

        private int[] stateStack = new int[16];
        private Object[] valueStack = new Object[16];
        public int size = 16;
        public int height = -1;

        public final void push(int state, Object value) {
            height++;
            if (size == height) {
                int[] newStateStack = new int[size * 2];
                System.arraycopy(stateStack, 0, newStateStack, 0, height);
                stateStack = newStateStack;


                Object[] newValueStack = new Object[size * 2];
                System.arraycopy(valueStack, 0, newValueStack, 0, height);
                valueStack = newValueStack;

                size *= 2;
            }

            stateStack[height] = state;

            valueStack[height] = value;
        }

        public final void pop() {
            height--;
        }

        public final void pop(int num) {
            // Avoid memory leaks... garbage collection is a white lie!
            if (num > 0) {
                java.util.Arrays.fill(valueStack, height - num + 1, height, null);

            }
            height -= num;
        }

        public final int stateAt(int i) {
            return stateStack[height - i];
        }

        public final Object valueAt(int i) {
            return valueStack[height - i];
        }

        // Print the state stack on the debug stream.
        public void print(java.io.PrintStream out) {
            out.print("Stack now");

            for (int i = 0; i < height; i++) {
                out.print(' ');
                out.print(stateStack[i]);
            }
            out.println();
        }
    }
    /**
     * Returned by a Bison action in order to stop the parsing process and
     * return success (<tt>true</tt>).  */
    public static final int YYACCEPT = 0;
    /**
     * Returned by a Bison action in order to stop the parsing process and
     * return failure (<tt>false</tt>).  */
    public static final int YYABORT = 1;
    /**
     * Returned by a Bison action in order to start error recovery without
     * printing an error message.  */
    public static final int YYERROR = 2;
    /**
     * Returned by a Bison action in order to print an error message and start
     * error recovery.  Formally deprecated in Bison 2.4.2's NEWS entry, where
     * a plan to phase it out is discussed.  */
    public static final int YYFAIL = 3;
    private static final int YYNEWSTATE = 4;
    private static final int YYDEFAULT = 5;
    private static final int YYREDUCE = 6;
    private static final int YYERRLAB1 = 7;
    private static final int YYRETURN = 8;
    private int yyerrstatus_ = 0;

    /**
     * Return whether error recovery is being done.  In this state, the parser
     * reads token until it reaches a known state, and then restarts normal
     * operation.  */
    public final boolean recovering() {
        return yyerrstatus_ == 0;
    }

    private int yyaction(int yyn, YYStack yystack, int yylen) {
        Object yyval;


        /* If YYLEN is nonzero, implement the default value of the action:
        `$$ = $1'.  Otherwise, use the top of the stack.

        Otherwise, the following line sets YYVAL to garbage.
        This behavior is undocumented and Bison
        users should not rely upon it.  */
        if (yylen > 0) {
            yyval = yystack.valueAt(yylen - 1);
        } else {
            yyval = yystack.valueAt(0);
        }

        yy_reduce_print(yyn, yystack);

        switch (yyn) {
            case 5:
                if (yyn == 5) /* Line 354 of lalr1.java  */ /* Line 20 of "ltcalc.y"  */ {
                    System.out.format("\t%.10g\n", ((Number) (yystack.valueAt(2 - (1)))));
                }
                ;
                break;


            case 6:
                if (yyn == 6) /* Line 354 of lalr1.java  */ /* Line 24 of "ltcalc.y"  */ {
                    sout("num " + ((Number) (yystack.valueAt(1 - (1)))));
                    yyval = opp.num(((Number) (yystack.valueAt(1 - (1)))));
                }
                ;
                break;


            case 7:
                if (yyn == 7) /* Line 354 of lalr1.java  */ /* Line 25 of "ltcalc.y"  */ {
                    sout(((Number) (yystack.valueAt(3 - (1)))) + " add " + ((Number) (yystack.valueAt(3 - (3)))));
                    yyval = opp.add(((Number) (yystack.valueAt(3 - (1)))), ((Number) (yystack.valueAt(3 - (3)))));
                }
                ;
                break;


            case 8:
                if (yyn == 8) /* Line 354 of lalr1.java  */ /* Line 26 of "ltcalc.y"  */ {
                    sout(((Number) (yystack.valueAt(3 - (1)))) + " minus " + ((Number) (yystack.valueAt(3 - (3)))));
                    yyval = opp.minus(((Number) (yystack.valueAt(3 - (1)))), ((Number) (yystack.valueAt(3 - (3)))));
                }
                ;
                break;


            case 9:
                if (yyn == 9) /* Line 354 of lalr1.java  */ /* Line 27 of "ltcalc.y"  */ {
                    sout(((Number) (yystack.valueAt(3 - (1)))) + " multiply " + ((Number) (yystack.valueAt(3 - (3)))));
                    yyval = opp.multiply(((Number) (yystack.valueAt(3 - (1)))), ((Number) (yystack.valueAt(3 - (3)))));
                }
                ;
                break;


            case 10:
                if (yyn == 10) /* Line 354 of lalr1.java  */ /* Line 28 of "ltcalc.y"  */ {
                    sout(((Number) (yystack.valueAt(3 - (1)))) + " divide " + ((Number) (yystack.valueAt(3 - (3)))));
                    yyval = opp.divide(((Number) (yystack.valueAt(3 - (1)))), ((Number) (yystack.valueAt(3 - (3)))));
                }
                ;
                break;


            case 11:
                if (yyn == 11) /* Line 354 of lalr1.java  */ /* Line 29 of "ltcalc.y"  */ {
                    sout(" negative " + ((Number) (yystack.valueAt(2 - (2)))));
                    yyval = opp.negative(((Number) (yystack.valueAt(2 - (2)))));
                }
                ;
                break;


            case 12:
                if (yyn == 12) /* Line 354 of lalr1.java  */ /* Line 30 of "ltcalc.y"  */ {
                    sout(((Number) (yystack.valueAt(3 - (1)))) + " pow " + ((Number) (yystack.valueAt(3 - (3)))));
                    yyval = opp.pow(((Number) (yystack.valueAt(3 - (1)))), ((Number) (yystack.valueAt(3 - (3)))));
                }
                ;
                break;


            case 13:
                if (yyn == 13) /* Line 354 of lalr1.java  */ /* Line 31 of "ltcalc.y"  */ {
                    sout("(" + ((Number) (yystack.valueAt(3 - (2)))) + ")");
                    yyval = opp.num(((Number) (yystack.valueAt(3 - (2)))));
                }
                ;
                break;




            /* Line 354 of lalr1.java  */
            /* Line 367 of "ltcalc.java"  */
            default:
                break;
        }

        yy_symbol_print("-> $$ =", yyr1_[yyn], yyval);

        yystack.pop(yylen);
        yylen = 0;

        /* Shift the result of the reduction.  */
        yyn = yyr1_[yyn];
        int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt(0);
        if (0 <= yystate && yystate <= yylast_
                && yycheck_[yystate] == yystack.stateAt(0)) {
            yystate = yytable_[yystate];
        } else {
            yystate = yydefgoto_[yyn - yyntokens_];
        }

        yystack.push(yystate, yyval);
        return YYNEWSTATE;
    }

    /* Return YYSTR after stripping away unnecessary quotes and
    backslashes, so that it's suitable for yyerror.  The heuristic is
    that double-quoting is unnecessary unless the string contains an
    apostrophe, a comma, or backslash (other than backslash-backslash).
    YYSTR is taken from yytname.  */
    private String yytnamerr_(String yystr) {
        if (yystr.charAt(0) == '"') {
            StringBuilder yyr = new StringBuilder();
            strip_quotes:
            for (int i = 1; i < yystr.length(); i++) {
                switch (yystr.charAt(i)) {
                    case '\'':
                    case ',':
                        break strip_quotes;

                    case '\\':
                        if (yystr.charAt(++i) != '\\') {
                            break strip_quotes;
                        }
                    /* Fall through.  */
                    default:
                        yyr.append(yystr.charAt(i));
                        break;

                    case '"':
                        return yyr.toString();
                }
            }
        } else if (yystr.equals("$end")) {
            return "end of input";
        }

        return yystr;
    }

    /*--------------------------------.
    | Print this symbol on YYOUTPUT.  |
    `--------------------------------*/
    private void yy_symbol_print(String s, int yytype,
            Object yyvaluep) {
        if (yydebug > 0) {
            yycdebug(s + (yytype < yyntokens_ ? " token " : " nterm ")
                    + yytname_[yytype] + " ("
                    + (yyvaluep == null ? "(null)" : yyvaluep.toString()) + ")");
        }
    }

    /**
     * Parse input from the scanner that was specified at object construction
     * time.  Return whether the end of the input was reached successfully.
     *
     * @return <tt>true</tt> if the parsing succeeds.  Note that this does not
     *          imply that there were no syntax errors.
     */
    public boolean parse() throws java.io.IOException {
        /// Lookahead and lookahead in internal form.
        int yychar = yyempty_;
        int yytoken = 0;

        /* State.  */
        int yyn = 0;
        int yylen = 0;
        int yystate = 0;

        YYStack yystack = new YYStack();

        /* Error handling.  */
        int yynerrs_ = 0;


        /// Semantic value of the lookahead.
        Object yylval = null;

        int yyresult;

        yycdebug("Starting parse\n");
        yyerrstatus_ = 0;


        /* Initialize the stack.  */
        yystack.push(yystate, yylval);

        int label = YYNEWSTATE;
        for (;;) {
            switch (label) {
                /* New state.  Unlike in the C/C++ skeletons, the state is already
                pushed when we come here.  */
                case YYNEWSTATE:
                    yycdebug("Entering state " + yystate + "\n");
                    if (yydebug > 0) {
                        yystack.print(yyDebugStream);
                    }

                    /* Accept?  */
                    if (yystate == yyfinal_) {
                        return true;
                    }

                    /* Take a decision.  First try without lookahead.  */
                    yyn = yypact_[yystate];
                    if (yyn == yypact_ninf_) {
                        label = YYDEFAULT;
                        break;
                    }

                    /* Read a lookahead token.  */
                    if (yychar == yyempty_) {
                        yycdebug("Reading a token: ");
                        yychar = yylex();

                        yylval = yylexer.getLVal();
                    }

                    /* Convert token to internal form.  */
                    if (yychar <= EOF) {
                        yychar = yytoken = EOF;
                        yycdebug("Now at end of input.\n");
                    } else {
                        yytoken = yytranslate_(yychar);
                        yy_symbol_print("Next token is", yytoken,
                                yylval);
                    }

                    /* If the proper action on seeing token YYTOKEN is to reduce or to
                    detect an error, take that action.  */
                    yyn += yytoken;
                    if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) {
                        label = YYDEFAULT;
                    } /* <= 0 means reduce or error.  */ else if ((yyn = yytable_[yyn]) <= 0) {
                        if (yyn == 0 || yyn == yytable_ninf_) {
                            label = YYFAIL;
                        } else {
                            yyn = -yyn;
                            label = YYREDUCE;
                        }
                    } else {
                        /* Shift the lookahead token.  */
                        yy_symbol_print("Shifting", yytoken,
                                yylval);

                        /* Discard the token being shifted.  */
                        yychar = yyempty_;

                        /* Count tokens shifted since error; after three, turn off error
                        status.  */
                        if (yyerrstatus_ > 0) {
                            --yyerrstatus_;
                        }

                        yystate = yyn;
                        yystack.push(yystate, yylval);
                        label = YYNEWSTATE;
                    }
                    break;

                /*-----------------------------------------------------------.
                | yydefault -- do the default action for the current state.  |
                `-----------------------------------------------------------*/
                case YYDEFAULT:
                    yyn = yydefact_[yystate];
                    if (yyn == 0) {
                        label = YYFAIL;
                    } else {
                        label = YYREDUCE;
                    }
                    break;

                /*-----------------------------.
                | yyreduce -- Do a reduction.  |
                `-----------------------------*/
                case YYREDUCE:
                    yylen = yyr2_[yyn];
                    label = yyaction(yyn, yystack, yylen);
                    yystate = yystack.stateAt(0);
                    break;

                /*------------------------------------.
                | yyerrlab -- here on detecting error |
                `------------------------------------*/
                case YYFAIL:
                    /* If not already recovering from an error, report this error.  */
                    if (yyerrstatus_ == 0) {
                        ++yynerrs_;
                        yyerror(yysyntax_error(yystate, yytoken));
                    }


                    if (yyerrstatus_ == 3) {
                        /* If just tried and failed to reuse lookahead token after an
                        error, discard it.  */

                        if (yychar <= EOF) {
                            /* Return failure if at end of input.  */
                            if (yychar == EOF) {
                                return false;
                            }
                        } else {
                            yychar = yyempty_;
                        }
                    }

                    /* Else will try to reuse lookahead token after shifting the error
                    token.  */
                    label = YYERRLAB1;
                    break;

                /*---------------------------------------------------.
                | errorlab -- error raised explicitly by YYERROR.  |
                `---------------------------------------------------*/
                case YYERROR:


                    /* Do not reclaim the symbols of the rule which action triggered
                    this YYERROR.  */
                    yystack.pop(yylen);
                    yylen = 0;
                    yystate = yystack.stateAt(0);
                    label = YYERRLAB1;
                    break;

                /*-------------------------------------------------------------.
                | yyerrlab1 -- common code for both syntax error and YYERROR.  |
                `-------------------------------------------------------------*/
                case YYERRLAB1:
                    yyerrstatus_ = 3;	/* Each real token shifted decrements this.  */

                    for (;;) {
                        yyn = yypact_[yystate];
                        if (yyn != yypact_ninf_) {
                            yyn += yyterror_;
                            if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) {
                                yyn = yytable_[yyn];
                                if (0 < yyn) {
                                    break;
                                }
                            }
                        }

                        /* Pop the current state because it cannot handle the error token.  */
                        if (yystack.height == 1) {
                            return false;
                        }


                        yystack.pop();
                        yystate = yystack.stateAt(0);
                        if (yydebug > 0) {
                            yystack.print(yyDebugStream);
                        }
                    }



                    /* Shift the error token.  */
                    yy_symbol_print("Shifting", yystos_[yyn],
                            yylval);

                    yystate = yyn;
                    yystack.push(yyn, yylval);
                    label = YYNEWSTATE;
                    break;

                /* Accept.  */
                case YYACCEPT:
                    return true;

                /* Abort.  */
                case YYABORT:
                    return false;
            }
        }
    }

    // Generate an error message.
    private String yysyntax_error(int yystate, int tok) {
        if (errorVerbose) {
            int yyn = yypact_[yystate];
            if (yypact_ninf_ < yyn && yyn <= yylast_) {
                StringBuffer res;

                /* Start YYX at -YYN if negative to avoid negative indexes in
                YYCHECK.  */
                int yyxbegin = yyn < 0 ? -yyn : 0;

                /* Stay within bounds of both yycheck and yytname.  */
                int yychecklim = yylast_ - yyn + 1;
                int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
                int count = 0;
                for (int x = yyxbegin; x < yyxend; ++x) {
                    if (yycheck_[x + yyn] == x && x != yyterror_) {
                        ++count;
                    }
                }

                // FIXME: This method of building the message is not compatible
                // with internationalization.
                res = new StringBuffer("syntax error, unexpected ");
                res.append(yytnamerr_(yytname_[tok]));
                if (count < 5) {
                    count = 0;
                    for (int x = yyxbegin; x < yyxend; ++x) {
                        if (yycheck_[x + yyn] == x && x != yyterror_) {
                            res.append(count++ == 0 ? ", expecting " : " or ");
                            res.append(yytnamerr_(yytname_[x]));
                        }
                    }
                }
                return res.toString();
            }
        }

        return "syntax error";
    }
    /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
    private static final byte yypact_ninf_ = -9;
    private static final byte yypact_[] = {
        -9, 12, -9, -9, 2, -9, 2, -9, 29, -8,
        20, 2, 2, 2, 2, 2, -9, -9, 11, 11,
        -8, -8, -8
    };

    /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
    doesn't specify something else to do.  Zero means the default is an
    error.  */
    private static final byte yydefact_[] = {
        2, 0, 1, 6, 0, 4, 0, 3, 0, 11,
        0, 0, 0, 0, 0, 0, 5, 13, 8, 7,
        9, 10, 12
    };

    /* YYPGOTO[NTERM-NUM].  */
    private static final byte yypgoto_[] = {
        -9, -9, -9, -4
    };

    /* YYDEFGOTO[NTERM-NUM].  */
    private static final byte yydefgoto_[] = {
        -1, 1, 7, 8
    };

    /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.  */
    private static final byte yytable_ninf_ = -1;
    private static final byte yytable_[] = {
        9, 15, 10, 0, 0, 3, 4, 18, 19, 20,
        21, 22, 2, 6, 0, 3, 4, 13, 14, 0,
        15, 0, 5, 6, 11, 12, 13, 14, 0, 15,
        0, 0, 17, 11, 12, 13, 14, 0, 15, 16
    };

    /* YYCHECK.  */
    private static final byte yycheck_[] = {
        4, 9, 6, -1, -1, 3, 4, 11, 12, 13,
        14, 15, 0, 11, -1, 3, 4, 6, 7, -1,
        9, -1, 10, 11, 4, 5, 6, 7, -1, 9,
        -1, -1, 12, 4, 5, 6, 7, -1, 9, 10
    };

    /* STOS_[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
    private static final byte yystos_[] = {
        0, 14, 0, 3, 4, 10, 11, 15, 16, 16,
        16, 4, 5, 6, 7, 9, 10, 12, 16, 16,
        16, 16, 16
    };

    /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
    to YYLEX-NUM.  */
    private static final short yytoken_number_[] = {
        0, 256, 257, 258, 45, 43, 42, 47, 259, 94,
        59, 40, 41
    };

    /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
    private static final byte yyr1_[] = {
        0, 13, 14, 14, 15, 15, 16, 16, 16, 16,
        16, 16, 16, 16
    };

    /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
    private static final byte yyr2_[] = {
        0, 2, 0, 2, 1, 2, 1, 3, 3, 3,
        3, 2, 3, 3
    };

    /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    First, the terminals, then, starting at \a yyntokens_, nonterminals.  */
    private static final String yytname_[] = {
        "$end", "error", "$undefined", "NUM", "'-'", "'+'", "'*'", "'/'", "NEG",
        "'^'", "';'", "'('", "')'", "$accept", "input", "line", "exp", null
    };

    /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
    private static final byte yyrhs_[] = {
        14, 0, -1, -1, 14, 15, -1, 10, -1, 16,
        10, -1, 3, -1, 16, 5, 16, -1, 16, 4,
        16, -1, 16, 6, 16, -1, 16, 7, 16, -1,
        4, 16, -1, 16, 9, 16, -1, 11, 16, 12,
        -1
    };

    /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
    private static final byte yyprhs_[] = {
        0, 0, 3, 4, 7, 9, 12, 14, 18, 22,
        26, 30, 33, 37
    };

    /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
    private static final byte yyrline_[] = {
        0, 15, 15, 16, 19, 20, 24, 25, 26, 27,
        28, 29, 30, 31
    };

    // Report on the debug stream that the rule yyrule is going to be reduced.
    private void yy_reduce_print(int yyrule, YYStack yystack) {
        if (yydebug == 0) {
            return;
        }

        int yylno = yyrline_[yyrule];
        int yynrhs = yyr2_[yyrule];
        /* Print the symbols being reduced, and their result.  */
        yycdebug("Reducing stack by rule " + (yyrule - 1)
                + " (line " + yylno + "), ");

        /* The symbols being reduced.  */
        for (int yyi = 0; yyi < yynrhs; yyi++) {
            yy_symbol_print("   $" + (yyi + 1) + " =",
                    yyrhs_[yyprhs_[yyrule] + yyi],
                    ((yystack.valueAt(yynrhs - (yyi + 1)))));
        }
    }

    /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
    private static final byte yytranslate_table_[] = {
        0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        11, 12, 6, 5, 2, 4, 2, 7, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 9, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 1, 2, 3, 8
    };

    private static byte yytranslate_(int t) {
        if (t >= 0 && t <= yyuser_token_number_max_) {
            return yytranslate_table_[t];
        } else {
            return yyundef_token_;
        }
    }
    private static final int yylast_ = 39;
    private static final int yynnts_ = 4;
    private static final int yyempty_ = -2;
    private static final int yyfinal_ = 2;
    private static final int yyterror_ = 1;
    private static final int yyerrcode_ = 256;
    private static final int yyntokens_ = 13;
    private static final int yyuser_token_number_max_ = 259;
    private static final int yyundef_token_ = 2;
    /* a reference to the lexer object */
    private Opperation opp = new Opperation();

    public static void sout(String str) {
        //System.out.println(str);
    }

    /* that's how you use the parser */
    public static void main(String args[]) throws java.io.IOException {
        System.out.println("Run");
        Yylex lexer = stringLex(" 1 + 3.4 / 4 - 2.1*3;");//new Yylex(System.in, EOF, NUM);
        YYParser yyparser = new YYParser(lexer);
        yyparser.parse();
    }

    public static Yylex stringLex(String data) {
        return new Yylex(new ByteArrayInputStream(data.getBytes()), EOF, NUM);
    }
}
